#include <bits/stdc++.h>
// 2025/02/08
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

struct{
    int r, c;
    char t;
} a[200001];

int n, q, dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0}, g[1001][1001][4], ans[200001], ANS;
bool canvis[1001][1001], vis[1001][1001], p[1001][1001];

void dfs(int x, int y){
    if (vis[x][y])
        return;
    vis[x][y] = true, ANS++;
    for (int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
        if (nx < 1 || nx > n || ny < 1 || ny > n || vis[nx][ny] || !g[nx][ny][i ^ 1])
            continue;
        dfs(nx, ny);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> q;
    for (int i = 1; i <= q; i++)
        cin >> a[i].r >> a[i].c >> a[i].t;
    for (int i = 1; i <= q; i++){
        if (a[i].t == 'L')
            g[a[i].r][a[i].c][0] = 1;
        else if (a[i].t == 'R')
            g[a[i].r][a[i].c][1] = 1;
        else if (a[i].t == 'U')
            g[a[i].r][a[i].c][2] = 1;
        else
            g[a[i].r][a[i].c][3] = 1;
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (!(g[i][j][0] || g[i][j][1] || g[i][j][2] || g[i][j][3]))
                g[i][j][0] = g[i][j][1] = g[i][j][2] = g[i][j][3] = 1;
    for (int i = 1; i <= n; i++){
        if (!vis[i][1] && g[i][1][0])
            dfs(i, 1);
        if (!vis[i][n] && g[i][n][1])
            dfs(i, n);
        if (!vis[1][i] && g[1][i][2])
            dfs(1, i);
        if (!vis[n][i] && g[n][i][3])
            dfs(n, i);
    }
    for (int i = q; i >= 1; i--){
        ans[i] = ANS;
        for (int j = 0; j < 4; j++)
            g[a[i].r][a[i].c][j] = 1;
        if (vis[a[i].r][a[i].c])
            continue;
        bool flag = false;
        for (int j = 0; j < 4; j++){
            int nx = a[i].r + dx[j], ny = a[i].c + dy[j];
            if (nx < 1 || nx > n || ny < 1 || ny > n || vis[nx][ny]){
                flag = true;
                break;
            }
        }
        if (!flag)
            continue;
        dfs(a[i].r, a[i].c);
    }
    for (int i = 1; i <= q; i++)
        cout << n * n - ans[i] << endl;
    return 0;
}